<?php
$config = parse_ini_file(ROOT_PATH . "/env", true);
$keys = array_keys($config);

//数据库配置
$db_config = [];
$prefix = "database.";
$len = strlen($prefix);
foreach ($keys as $key) {
    if (substr($key, 0, $len) == $prefix) {
        if (isset($config[$key])) {
            $newKey = substr($key, $len);
            $db_config[$newKey] = $config[$key];
        }
    }
}
$returnData['db'] = $db_config;

//数据库连接池配置
$returnData['db_pool'] = [];
if (isset($config['db_pool']) && $config['db_pool']) {
    $returnData['db_pool'] = $config['db_pool'];
}

//redis 配置
$returnData['redis'] = [];
if (isset($config['redis']) && $config['redis']) {
    $returnData['redis'] = $config['redis'];
}


//redis连接池 配置
$returnData['redis_pool'] = [];
if (isset($config['redis_pool']) && $config['redis_pool']) {
    $returnData['redis_pool'] = $config['redis_pool'];
}

return $returnData;
